<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>angular js </title>
    <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        //1.创建模块【-
        var app=angular.module("myApp",[]);//引用其他模块
        //2.创建控制器 用来控制层和view之间的关联
        app.controller("myController",function($scope){
            //3.创建具体的操作函数
            $scope.add=function(){
                return parseInt($scope.x) +  parseInt($scope.y);
            };
            $scope.minus=function(){
                return parseInt($scope.x) -  parseInt($scope.y);
            };
            $scope.multiply=function(){
                return parseInt($scope.x) *  parseInt($scope.y);
            };
            $scope.divide=function(){
                return parseInt($scope.x) /  parseInt($scope.y);
            };
        });
    </script>
</head>
<!--4.绑定模块和绑定控制器-->
<body ng-init="x=0;y=0" ng-app="myApp" ng-controller="myController">
<h2>计算器</h2>
<hr>

<div>
    <!--5.绑定模型数据-->
    <input   type="text" ng-model="x"><br>
    <input   type="text" ng-model="y">
    <!-- 6.结果方法调用-->
    <button ng-click="add()">结果</button>
    <br>
    加：{{add()}}<br>
    减：{{minus()}}<br>
    乘：{{multiply()}}<br>
    除：{{divide()}}
</div>
<img src="2.jpg"/>
</body>
</html>
